<template>
  <div class="app-container">
    <el-page-header @back="goBack"> </el-page-header>
    <div>
      <el-table
        v-loading="loading"
        border
        :data="dataList"
        height="65vh"
        row-key="pieceId"
      >
        <!-- <el-table-column type="selection" width="55" /> -->
        <el-table-column label="序号" width="60" type="index" align="center" />
        <el-table-column
          label="生产单编码"
          prop="produceNo"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          label="印刷管理序号"
          min-width="120"
          prop="producePieceNo"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="书刊编码"
          min-width="120"
          prop="bookNo"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="书刊名称"
          min-width="160"
          prop="produceName"
          align="center"
        ></el-table-column>
        <el-table-column
          label="品种"
          prop="breedType"
          min-width="100"
          align="center"
        ></el-table-column>
        <el-table-column
          label="印张"
          width="70"
          prop="sheet"
          align="center"
        ></el-table-column>
        <el-table-column
          label="贴标"
          prop="pieceView"
          min-width="70"
          align="center"
        ></el-table-column>
        <el-table-column
          label="印数"
          prop="printAmount"
          min-width="80"
          align="center"
        ></el-table-column>
        <el-table-column
          label="机台"
          min-width="120"
          prop="machineName"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="机长"
          min-width="120"
          prop="userName"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="车间"
          min-width="120"
          prop="workshopName"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
                  label="纸张编码"
                  prop="paperNo"
                  min-width="80"
                  align="center"
                ></el-table-column> 
                <el-table-column
                   label="版材尺寸"
                    min-width="120"
                    prop="sheetSize"
                     align="center"
                  > 
                  <template #default="scope">
                    <dict-tag
                      :options="ems_machine_info_size"
                      :value="scope.row.sheetSize"
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="组成"
                  min-width="160"
                  prop="composition"
                  align="center"
                >
                  <template #default="scope">
                    <dict-tag
                      :options="ems_order_make_up"
                      :value="scope.row.composition"
                    />
                  </template>
                </el-table-column> -->
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>
<script setup>
import { getMachineAndPieceByTechnology } from "@/api/production/printReport.js";
import useTagsViewStore from "@/store/modules/tagsView";
const { proxy } = getCurrentInstance();
const loading = ref(true);
const dataList = ref([]);
const showSearch = ref(true);
const total = ref(0);
const router = useRouter();
const route = useRoute();
const workshopOptions = ref([]);
const flag = ref(true);
const tagsViewStore = useTagsViewStore();

const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 50,
    breedType: undefined,
    machineType: undefined,
    produceNo: undefined,
  },
});
const { queryParams } = toRefs(data);
const { ems_machine_info_size, ems_order_make_up, ems_order_print_color } =
  proxy.useDict(
    "ems_machine_info_size",
    "ems_order_make_up",
    "ems_order_print_color"
  );

const getList = () => {
  loading.value = true;
  if (route.query?.breedType) {
    queryParams.value.breedType = route.query.breedType;
    queryParams.value.produceNo = route.query.produceNo;
    queryParams.value.machineType = route.query.machineType;
  }

  getMachineAndPieceByTechnology(queryParams.value)
    .then((res) => {
      loading.value = false;
      dataList.value = res.rows;
      total.value = res.total;
    })
    .catch((err) => {
      loading.value = false;
    });
};

// 查看
const handleView = (row) => {
  router.push({
    path: "/production/printReport/printReportDetails",
    query: {
      id: row.reportId,
      info: true,
    },
  });
};
// 搜索
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

getList();
//  返回
const goBack = () => {
  //router.push({ path: "/production/orderProgress" });
  // router.replace({ path: "/production/orderProgress" });
  setTimeout(() => {
    router.go(-1);
    tagsViewStore.delView(route);
  }, 0);
};
</script>
    
    <style lang="scss" scoped></style>
    